package server;

import java.rmi.RemoteException;

public class BillingServerSecure implements IBillingServerSecure {

	private PriceSteps priceSteps = new PriceSteps();
	
	public BillingServerSecure() {
		
	}
	
	@Override
	public PriceSteps getPriceSteps() throws RemoteException {
		
		return priceSteps;
	}

	@Override
	public void createPriceStep(double startPrice, double endPrice, double fixedPrice, double variablePricePercent) throws RemoteException {

		if (startPrice < 0 || endPrice < 0 || fixedPrice < 0 || variablePricePercent < 0)
			throw new RemoteException("ERROR: A value < 0 is not allowed");
		
		if (!priceSteps.add(startPrice, endPrice, fixedPrice, variablePricePercent))
			throw new RemoteException("ERROR: Invalid Price step [" + startPrice + " - " + endPrice + "]");
		
	}

	@Override
	public void deletePriceStep(double startPrice, double endPrice) throws RemoteException {
		
		if (startPrice < 0 || endPrice < 0)
			throw new RemoteException("ERROR: A value < 0 is not allowed");
		
		if(!priceSteps.delete(startPrice, endPrice))
			throw new RemoteException("ERROR: Price step [" + startPrice + " " + endPrice + "] does not exist");
		
	}

	@Override
	public void billAuction(String user, long auctionID, double price) throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Bill getBill(String user) throws RemoteException {
		// TODO Auto-generated method stub
		return null;
	}

}
